class test{
	public static void main(String[] args) {

		int year=1998,month=2,d=28;

		int w=0,c=0,y=0,m=0;
	    c=year/100;
	    y=year%100;
	    if(month<3){
			m=month+12;
			y--;
	    }
	    else m=month;
	    int day = (y+y/4+c/4-2*c+26*(m+1)/10+d-1)%7;
	    System.out.println(day);
	}
}